package com.gcsoftware.web.mapper;

import com.gcsoftware.web.mapper.providers.SysLogProvider;
import com.gcsoftware.web.beans.T_COM_SYS_LOGS;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by qs on 2018/3/25.
 */
@Mapper
public interface T_COM_SYS_LOGMAPPER {
    @Insert("INSERT INTO T_COM_SYS_LOGS(c_LOG_ID,c_LOGIN_ID,c_USER_ID,c_LOGIN_IP,c_LOG_TYPE,c_OPERATE_DETAIL,c_LOG_STATUS)" +
            "VALUES(#{c_LOG_ID},#{c_LOGIN_ID},#{c_USER_ID},#{c_LOGIN_IP},#{c_LOG_TYPE},#{c_OPERATE_DETAIL},#{c_LOG_STATUS})")
    public int insertSysLog(T_COM_SYS_LOGS log) ;

    @Select("SELECT max(c_LOG_ID) FROM T_COM_SYS_LOGS")
    public String getMaxId();

    @SelectProvider(type=SysLogProvider.class,
            method="loginLogSql")
    public List<T_COM_SYS_LOGS> queryLoginLogs(@Param(value = "c_LOGIN_NAME") String c_LOGIN_NAME,@Param(value = "c_START_TIME")String c_START_TIME,@Param(value = "c_END_TIME") String c_END_TIME);

    @Select("SELECT usr.c_LOGIN_NAME ,log.c_LOGIN_IP,to_char(D_LOG_TIME, 'yyyy-MM-dd hh24:mi:ss') c_LOGIN_TIME,C_OPERATE_DETAIL FROM T_COM_SYS_LOGS log,t_COM_SYS_USER usr WHERE c_LOGIN_ID = #{c_LOGIN_ID} and log.c_USER_ID = usr.c_USER_ID")
    public List<T_COM_SYS_LOGS> queryOprLogs(@Param(value = "c_LOGIN_ID") String c_LOGIN_ID);

    public int deleteLogs();
}
